<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2018/11/9
 * Time: 09:26
 */

namespace app\api\model;


class CardThumbsup extends BaseModel
{
    protected $hidden = ['create_time'];
    protected $autoWriteTimestamp = true;
    protected $updateTime = false;

    /**
     * 创建点赞
     * @param $data
     * @return $this
     */
    public static function createThumbs($data){
        return self::create($data);
    }

    /**
     * 发现点赞
     * @param $uid
     * @param $w_id
     * @return null|static
     */
    public static function findThumbs($uid,$w_id){
        return self::get(function($query) use($uid,$w_id){
            $query->where('w_id', $w_id)->where('user',$uid);
        });
    }

    /**
     * 获取点赞量
     * @param $w_id
     * @return false|\PDOStatement|string|\think\Collection
     */
    public static function getThumbs($w_id){
        return self::where('w_id','=',$w_id)->field('user')->select();
    }


}